import { ApiProperty } from '@nestjs/swagger';
import { IsDefined, IsNotEmpty, IsString, Matches } from 'class-validator';

export class loginReq {
    @IsNotEmpty({ message: '手机号码不能为空' })
    @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式错误' })
    @ApiProperty({ description: '手机号', example: '', required: true })
    public mobileNo!: string

    @IsNotEmpty({ message: '密码不能为空' })
    // @Matches(/^(?=.*[a-zA-Z])(?=.*\d).{6,}$/, { message: '密码格式错误，长度不能小于6位，且必须包含数字和字母' })
    @ApiProperty({ description: '密码', example: '', required: true })
    public password!: string
}

export class registerReq {
    @IsNotEmpty({ message: '手机号不能为空' })
    @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式错误' })
    @ApiProperty({ description: '手机号', example: '', required: true })
    public phoneData!: string

    @IsNotEmpty({ message: '密码不能为空' })
    @Matches(/^(?=.*[a-zA-Z])(?=.*\d).{6,}$/, { message: '密码格式错误，长度不能小于6位，且必须包含数字和字母' })
    @ApiProperty({ description: '密码', example: '', required: true })
    public passData!: string

    @ApiProperty({ description: '邀请码', example: '', required: false })
    public invData?: string

    @IsNotEmpty({ message: '验证码不能为空' })
    @ApiProperty({ description: '验证码', example: '', required: true })
    public verCode!: string
}

export class _idReq {
    @IsNotEmpty({ message: '用户信息有误' })
    @ApiProperty({ description: '用户id', example: '', required: true })
    public user_id!: string

}

export class setPwd {
    @IsNotEmpty({ message: '用户信息有误' })
    @ApiProperty({ description: '用户id', example: '', required: true })
    public user_id!: string

    @IsNotEmpty({ message: '手机号不能为空' })
    @Matches(/^1[3-9]\d{9}$/, { message: '手机号格式错误' })
    @ApiProperty({ description: '手机号', example: '', required: true })
    public phoneData!: string

    @IsNotEmpty({ message: '验证码不能为空' })
    @ApiProperty({ description: '验证码', example: '', required: true })
    public verCode!: string

    @IsNotEmpty({ message: '旧密码不能为空' })
    @Matches(/^(?=.*[a-zA-Z])(?=.*\d).{6,}$/, { message: '密码格式错误，长度不能小于6位，且必须包含数字和字母' })
    @ApiProperty({ description: '旧密码', example: '', required: true })
    public oldPwd!: string

    @IsNotEmpty({ message: '新密码不能为空' })
    @Matches(/^(?=.*[a-zA-Z])(?=.*\d).{6,}$/, { message: '密码格式错误，长度不能小于6位，且必须包含数字和字母' })
    @ApiProperty({ description: '新密码', example: '', required: true })
    public newPwd!: string

}


// 验证码
export const verCodeObj: { [phoneNo: string]: string } = {};

